<?php

// +----------------------------------------------------------------------
// | 版权所有 2017-2027 云南环拓科技有限公司，并保留所有权利。
// +----------------------------------------------------------------------
// | Copyright (c) 2017-2027 http://www.yn123.com All rights reserved.
// +----------------------------------------------------------------------
// | Notice: This code is not open source, it is strictly prohibited
// |         to distribute the copy, otherwise it will pursue its
// |         legal responsibility.
// | 注意：  这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用,
// |        不允许对程序代码以任何形式任何目的的再发布。
// +----------------------------------------------------------------------
// | Author: feraner <feraner@163.com> 
// | Date: 2019/11/27
// +----------------------------------------------------------------------

namespace app\index\controller;

use think\App;
use think\Db;

/**
 *  用户钱包类
 * Class Userwallet
 * @package app\index\controller
 * @author feraner<feraner@163.com>
 * @date 2019/11/27
 */
class Userwallet extends UserBase
{

    public function __construct(App $app = null)
    {
        parent::__construct($app);
    }


    /**
     * 钱包中心首页
     * @return mixed
     */
    public function index()
    {
        return $this->fetch();
    }


    /**
     * 购买发布豆
     * @return mixed
     */
    public function buyBean()
    {

        return $this->fetch();
    }


    public function buyBeanByActive()
    {
        $activeId = $this->request->param('id', 0);

        $this->assign('activeId', $activeId);

        return $this->fetch();
    }




    /**
     * 发布豆记录
     * @return mixed
     */
    public function beanRecord()
    {
        $type = $this->request->param('type', 1);

        $this->assign('type', $type);
        return $this->fetch() ;
    }


    /**
     * 积分记录
     * @return mixed
     */
    public function creditsRecord()
    {

        $type = $this->request->param('type', 0);

        $this->assign('type', $type);

        return $this->fetch();
    }


    /**
     * 微信支付界面
     * @return mixed
     */
    public function wechatPay()
    {
        $chargeId = $this->request->param('chargeId', 0);
        if ($chargeId) {
            $chargeInfo = Db::name('user_charge')
                ->where('user_id', $this->userId)
                ->where('id', $chargeId)
                ->where('status', 0)
                ->value('id') ?: 0;
            if ($chargeInfo) {
                $this->assign('chargeId', $chargeId);
                return $this->fetch();
            }
        }
        $this->error('参数错误!');
    }


}
